CC ?= gcc

SHARED := -fPIC --shared

LUA_CLIB_PATH ?= luaclib

SKYNET_BUILD_PATH ?= ./skynet

CFLAGS = -g -O2 -Wall -I$(LUA_INC) 

LUA_STATICLIB := ./skynet/3rd/lua/liblua.a
LUA_LIB ?= $(LUA_STATICLIB)
LUA_INC ?= ./skynet/3rd/lua

LUA_CLIB = cjson websocketnetpack protobuf

TLS_MODULE=ltls
TLS_LIB=
TLS_INC=

all	: $(LUA_CLIB_PATH)/websocketnetpack.so $(LUA_CLIB_PATH)/protobuf.so

$(LUA_CLIB_PATH)/websocketnetpack.so : lualib-src/lua-websocketnetpack.c | $(LUA_CLIB_PATH)
	$(CC) $(CFLAGS) $(SHARED) -I$(SKYNET_BUILD_PATH)/skynet-src $^ -o $@

$(LUA_CLIB_PATH)/ltls.so : lualib-src/ltls.c | $(LUA_CLIB_PATH)
	$(CC) $(CFLAGS) $(SHARED) -Iskynet-src -L$(TLS_LIB) -I$(TLS_INC) $^ -o $@ -lssl
	
clean :
	rm -f $(LUA_CLIB_PATH)/*.so
